package com.hh.tc.ui

import android.os.Build
import com.hh.base.util.ext.DateType
import com.hh.base.util.ext.append
import com.hh.base.util.ext.toDate
import com.hh.base.util.ext.toShow
import java.time.LocalDate
import java.time.format.DateTimeFormatter
import java.util.Locale

/**
 * Create By hHui on 2025/4/8 11:38
 *
 * @description
 */
object CoverUtil {
    /**
     * 2025-04-07  -----> 4月7日(周五)
     */
    @JvmStatic
    fun toDayShow(data: String): String {
        val array = data.split("-")
        val a = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            val date = LocalDate.parse(data)
            // 创建中文格式的星期格式化器
            val weekFormatter = DateTimeFormatter.ofPattern("E", Locale.CHINA)
            date.format(weekFormatter)
        } else {
            ""
        }
        return "${array[1]}月${array[2]}日(${a})"
    }

    @JvmStatic
    fun countToShow(count: Int): String {
        return "每日${count}次"
    }

    /**
     * 2025-04-08 11:48:06 ---->11:48
     */
    @JvmStatic
    fun toHourMinShow(data: String?): String {
        if (data == null) {
            return "-"
        }
        val date = data.toDate()
        return date.toShow(DateType.H_M)
    }

    @JvmStatic
    fun toHourMinFinishShow(data: String?): String {
        if (data == null) {
            return "-"
        }
        val date = data.toDate()
        return "${date.toShow(DateType.H_M)}(已完成)"
    }

    @JvmStatic
    fun month2Show(month: String): String {
        return month.replace("-", "年").append("月")
    }
}